package org.tuo.util.handler;

import org.apache.commons.dbutils.ColumnHandler;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 自定义处理类
 */
public class BigDecimalColumnHandler implements ColumnHandler {
    @Override
    public boolean match(Class<?> propType) {
        return propType.equals(BigDecimal.class);
    }

    @Override
    public Object apply(ResultSet rs, int columnIndex) throws SQLException {
        return BigDecimal.valueOf(Double.valueOf(rs.getString(columnIndex)));
    }
}
